import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBBaseRouter/YBNavigator.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBColor/YBColor.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBCommonToast/YBCommonToastPage.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBImageStyle/YBImageStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBJsonToModel/YBBaseModel.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBNetWorkModule/YBBaseMineNetWork/YBBaseMineNetWork.dart';

class YBNewPassWordPage extends StatefulWidget {
  @override
  _YBNewPassWordPageState createState() => _YBNewPassWordPageState();
}

class _YBNewPassWordPageState extends State<YBNewPassWordPage> {

  TextEditingController _editingController = TextEditingController();
  TextEditingController _enterEditingController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Container(
      child:Scaffold(
        appBar: AppBar(
          elevation: 0,
          title: Text(
            YBChineseText.mineNewPassWordTitle,
            style: YBTextStyle.TextStyle30313320Medium,
          ),
        ),
        body: SingleChildScrollView(
          child: Padding(
             padding: EdgeInsets.fromLTRB(YBTextStyle.adapterSize20, YBTextStyle.adapterSize40, YBTextStyle.adapterSize20, YBTextStyle.adapterSize20),
             child: Column(
               mainAxisAlignment: MainAxisAlignment.start,
               crossAxisAlignment: CrossAxisAlignment.stretch,
               children: [
                 Container(
                   height: YBTextStyle.adapterSize50,
                   color: YBColor.white,
                   child: Row(
                     children: [
                       Container(
                         child: Image.asset(YBImageStyle.getImagePath('login_password')),
                       ),
                       Container(
                         width: 8,
                       ),
                       Expanded(
                         child: TextField(
                           decoration: InputDecoration(
                             hintText: YBChineseText.mineInputYanZhengMaTitle,
                             border: InputBorder.none,
                           ),
                           obscureText: true,
                           controller: _editingController,
                         ),
                       ),
                     ],
                   ),
                 ),
                 Container(
                   color: YBColor.colorF5F5F7,
                   height: 1,
                 ),
                 Container(
                   height: 1,
                 ),
                 Container(
                   height: YBTextStyle.adapterSize50,
                   color: YBColor.white,
                   child: Row(
                     children: [
                       Container(
                         child: Image.asset(YBImageStyle.getImagePath('login_password')),
                       ),
                       Container(
                         width: YBTextStyle.adapterSize8,
                       ),
                       Expanded(
                         child: TextField(
                           decoration: InputDecoration(
                             hintText: YBChineseText.mineInputYanZhengMaTitle,
                             border: InputBorder.none,
                           ),
                           obscureText: true,
                           controller: _enterEditingController,
                         ),
                       ),
                     ],
                   ),
                 ),
                 Container(
                   color: YBColor.colorF5F5F7,
                   height: 1,
                 ),
                 Container(
                   height: YBTextStyle.adapterSize30,
                 ),
                 Container(
                   height: YBTextStyle.adapterSize44,
                   child: RawMaterialButton(
                       child: Text(YBChineseText.mineEnterXiuGaiPassWordTitle,style:YBTextStyle.TextStyleFFFFFF16Medium,),
                       fillColor: YBColor.commonThemeColor,
                       shape: RoundedRectangleBorder(
                         borderRadius: BorderRadius.circular(YBTextStyle.adapterSize8),
                       ),
                       onPressed:(){
                         if (_editingController.text != _enterEditingController.text){
                           YBToast.showToastInfo(YBChineseText.mineEnterTwoPassWordTitle);
                           return;
                         }
                         _getNewPassWord(_editingController.text);
                       }),
                 ),
               ],
             ),
          ),
        ),
      ),
    );
  }

  void _getNewPassWord(String passWordStr){
    YBMineNetWork.mineSettingNewPassWordChangeData({
      "customerPassword":passWordStr,
      "sysCode":"xg_youbang"
    },success: (data){
      print("object----$data");
      bool bodyBool = data as bool;
      if (bodyBool == true){
         YBToast.showToastInfo("密码修改成功");
         Future.delayed(Duration(seconds: 1),(){
           YBNavigatorUtil.goBack(context);
         });

      }
    },fail: (error){
      print("object----$error");
    });
  }

}
